<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<div class="col-lg-6">
    <form id="form1" method="POST" onsubmit="return false" action="" autoscroll="true">
        <!-- action="{% url 'threat_info' %}" method="POST" -->
        {% csrf_token %}
        <div class="input-group">
            <!-- /btn-group -->
            <input type="text" class="form-control" placeholder="请输入域名或IP" name="ip" required>
            <span class="input-group-btn">
                <button class="btn btn-default" type="submit" onclick="querythreatinfo()">
                    <span class="glyphicon glyphicon-search" aria-hidden="true"></span>Search
                </button>
            </span>
        </div>
    </form>
    <!-- /input-group -->
</div>
<!-- /.col-lg-6 -->
<div class="panel-body">
    <!-- Table -->
    <table class="table" id='viewthreatinfo'>
        <tr>
            <th data-field="Name" data-editable="true">是否恶意地址</th>
            <th data-field="ParentName">运营商</th>
            <th data-field="ParentName">国家</th>
            <th data-field="ParentName">省</th>
            <th data-field="ParentName">市</th>
            <th data-field="ParentName">严重级别</th>
            <th data-field="ParentName">情报更新时间</th>
        </tr>
        <tr>
            <td id='is_malicious'></td>
            <td id='carrier'></td>
            <td id='country'></td>
            <td id='province'></td>
            <td id='city'></td>
            <td id='severity'></td>
            <td id='update_time'></td>
        </tr>
    </table>


    <!--引入jquery-->
    <script src="/static/js/jquery-3.3.1.min.js"></script>
    <script src="/static/js/jquery-3.3.1.js"></script>
    <!--引入bootstrap-->
    <link rel="stylesheet" href="/static/css/bootstrap.min.css">
    <link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">
    <link rel="stylesheet" href="/static/css/bootstrap.css">
    <link rel="stylesheet" href="/static/css/bootstrap-theme.css">
    <script src="/static/js/bootstrap.min.js"></script>



    <script>
        function querythreatinfo() {
            $.ajax({
                type: 'POST', //请求方式
                dataType: 'JSON', //数据格式
                url: 'threat_info', //后台请求的数据
                data: $('#form1').serialize(),
                async: false, //是否异步请求
                success: function (result) { //如果请求成功，返回数据。
                    //alert("请求成功！")
                    console.log(result)
                    var res = result;
                    //console.log(res[0]);
                    if (res[0] == "否")
                    {
                        document.getElementById("is_malicious").innerHTML = "否";
                    }
                    else {
                        document.getElementById("is_malicious").innerHTML = "是";
                    }
                    document.getElementById("is_malicious").innerHTML = res[0];
                    document.getElementById("carrier").innerHTML = res[1];
                    document.getElementById("country").innerHTML = res[2];
                    document.getElementById("province").innerHTML = res[3];
                    document.getElementById("city").innerHTML = res[4];
                    document.getElementById("severity").innerHTML = res[5];
                    document.getElementById("update_time").innerHTML = res[6];
                },
                error: function () {
                    console.log();
                    alert("异常！");

                }
            })
        }
    </script>